import { IsNotEmpty, MinLength, MaxLength, IsMobilePhone } from "class-validator";
import { ApiProperty } from '@nestjs/swagger';
import { IsScriptContent } from "src/common/utils/validate";

export class CreateUserDto {
    @ApiProperty({ example: 'kitty', description: '用户名' }) //添加这里即可
    @IsNotEmpty({ message: '用户名不能为空' })
    @IsScriptContent({ message: "禁止输入敏感内容" })
    username: string;

    @ApiProperty({ example: '12345678', description: '密码' })
    @IsNotEmpty({ message: '密码不能为空' })
    @MinLength(6, {
        message: '密码长度不能小于6位',
    })
    @MaxLength(20, {
        message: '密码长度不能超过20位',
    })
    password: string;

    @ApiProperty({ example: `13511231111`, description: "手机号", required: false })
    @IsMobilePhone('zh-CN', {}, { message: '手机号码格式错误' })
    phone: string

    @ApiProperty({ example: `{key1:'属性1',key2:'属性2'}`, description: "body为可选参数", required: false })
    body: {
        [key: string]: string
    }
}
